<?php
/**
 * Contains global message functions.
 */
class Message
{
	/**
	 * Sends a flash message, supporting both PHP and AJAX methods.
	 * @param string $key key identifying the flash message
	 * @param mixed $value flash message
	 * @param mixed $defaultValue if this value is the same as the flash message, the flash message
	 */
	static public function flash($key, $value, $defaultValue=NULL)
	{
		if(!Yii::app()->request->isAjaxRequest)
			Yii::app()->user->setFlash($key, $value, $defaultValue);
		else
			echo "<div class='flash-$key'>$value</div>";
	}

 	static public function bitacora($accion)
    {
        $user = Yii::app()->user->name;
       // if ($user != NULL){
       		$fechaAhora = new CDbExpression('NOW()'); 
	        $model = new Bitacora;
	        $model->descripcion = "$accion [User: $user]";
	        $model->fecha = $fechaAhora;//'2014-05-27';
	        $model->hora = $fechaAhora;//'12:00:00';
	        $model->save();


    //	}
    }
}